import { request } from '@vipl520/utils'
const path = '/' + import.meta.env.VITE_BASE_ADDON_NAME + '/addons.addon/'

export function getList(page, size, search) {
  return request({
    url: path + 'index',
    method: 'get',
    params: { page, size, search, order: 'id desc' }
  })
}

export function getAddonById(id) {
  return request({
    url: path + 'getAddonById',
    method: 'post',
    data: { id }
  })
}
// 删除
export function del(id) {
  return request({
    url: path + 'delete',
    method: 'post',
    data: { id }
  })
}

// 清空
export function clear() {
  return request({
    url: path + 'clear',
    method: 'post'
  })
}

export function getForm(id) {
  return request({
    url: path + 'getForm',
    method: 'post',
    data: { id }
  })
}

export function getCreateTableSql(aid) {
  return request({
    url: path + 'getCreateTableSql',
    method: 'post',
    data: { aid }
  })
}

export function getUpgradeSql(aid) {
  return request({
    url: path + 'getUpgradeSql',
    method: 'post',
    data: { aid }
  })
}

export function saveUpgradeSql(aid, sql) {
  return request({
    url: path + 'saveUpgradeSql',
    method: 'post',
    data: { aid, sql }
  })
}
